home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4014 / 4014.xpi / chrome / content / urlbar.xml < prev   
Extensible Markup Language  |  2009-11-24  |  22KB  |  563 lines

  1. ∩╗┐<?xml version="1.0" encoding="UTF-8"?>
  2.  
  3. <!-- ***** BEGIN LICENSE BLOCK *****
  4.    - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5.    -
  6.    - The contents of this file are subject to the Mozilla Public License Version
  7.    - 1.1 (the "License"); you may not use this file except in compliance with
  8.    - the License. You may obtain a copy of the License at
  9.    - http://www.mozilla.org/MPL/
  10.    -
  11.    - Software distributed under the License is distributed on an "AS IS" basis,
  12.    - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  13.    - for the specific language governing rights and limitations under the
  14.    - License.
  15.    -
  16.    - The Original Code is mozilla.org browser.
  17.    -
  18.    - The Initial Developer of the Original Code is
  19.    -   D├úo Gottwald <dao@design-noir.de>.
  20.    - Portions created by the Initial Developer are Copyright (C) 2007
  21.    - the Initial Developer. All Rights Reserved.
  22.    -
  23.    - Alternatively, the contents of this file may be used under the terms of
  24.    - either the GNU General Public License Version 2 or later (the "GPL"), or
  25.    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  26.    - in which case the provisions of the GPL or the LGPL are applicable instead
  27.    - of those above. If you wish to allow use of your version of this file only
  28.    - under the terms of either the GPL or the LGPL, and not to allow others to
  29.    - use your version of this file under the terms of the MPL, indicate your
  30.    - decision by deleting the provisions above and replace them with the notice
  31.    - and other provisions required by the GPL or the LGPL. If you do not delete
  32.    - the provisions above, a recipient may use your version of this file under
  33.    - the terms of any one of the MPL, the GPL or the LGPL.
  34.    -
  35.    - ***** END LICENSE BLOCK ***** -->
  36.  
  37. <bindings xmlns="http://www.mozilla.org/xbl"
  38.           xmlns:html="http://www.w3.org/1999/xhtml"
  39.           xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  40.           xmlns:xbl="http://www.mozilla.org/xbl">
  41.  
  42.   <binding id="urlbar" extends="chrome://browser/content/urlbarBindings.xml#urlbar">
  43.     <content sizetopopup="pref">
  44.       <xul:hbox class="autocomplete-textbox-container" flex="1">
  45. <!-- fission: -->
  46.         <xul:stack flex="1">
  47.           <children includes="progressmeter"/>
  48.           <xul:hbox class="autocomplete-textbox-container-fission">
  49. <!-- /fission -->
  50.         <xul:hbox class="textbox-icon-box"
  51.                   onmouseover="gURLBar._iconWasHovered = true;">
  52.           <children includes="image|deck|stack|box">
  53.             <xul:image class="autocomplete-icon" allowevents="true"/>
  54.           </children>
  55.         </xul:hbox>
  56.  
  57.         <xul:stack flex="1" anonid="textbox-input-box" class="textbox-input-box">
  58.           <xul:hbox anonid="textbox-input-box-inner" xbl:inherits="tooltiptext=inputtooltiptext"
  59.                     flex="1" align="center">
  60.             <children/>
  61.             <html:input anonid="input" class="autocomplete-textbox textbox-input"
  62.                         flex="1" allowevents="true"
  63.                         xbl:inherits="tooltiptext=inputtooltiptext,onfocus,onblur,value,type,maxlength,disabled,size,readonly,userAction"/>
  64.           </xul:hbox>
  65.           <xul:hbox anonid="presentation-box" class="textbox-presentation-box"
  66.                     flex="1" align="center"
  67.                     onmousedown="gURLBar.focus();"
  68.                     ondragover="nsDragAndDrop.dragOver(event, gURLBar);"
  69.                     ondragdrop="nsDragAndDrop.drop(event, gURLBar);"
  70.                     ondragexit="nsDragAndDrop.dragExit(event, gURLBar);">
  71.             <xul:scrollbox anonid="presentation" class="textbox-presentation" flex="1"
  72.                            onoverflow="gURLBar.contentIsCropped = true;"
  73.                            onunderflow="gURLBar.contentIsCropped = false;">
  74.               <xul:hbox anonid="prePath" class="textbox-presentation-segment textbox-presentation-prePath">
  75.                 <xul:label anonid="protocol" class="textbox-presentation-protocol"/>
  76.                 <xul:label anonid="subdomain" class="textbox-presentation-subdomain"/>
  77.                 <xul:label anonid="domain" class="textbox-presentation-domain"/>
  78.                 <xul:label anonid="port" class="textbox-presentation-port"/>
  79.               </xul:hbox>
  80.               <xul:hbox anonid="pathFile" class="textbox-presentation-segment textbox-presentation-pathFile">
  81.                 <xul:label anonid="file" class="textbox-presentation-file"/>
  82.                 <xul:label anonid="query" class="textbox-presentation-query"/>
  83.                 <xul:label anonid="fragment" class="textbox-presentation-fragment"/>
  84.               </xul:hbox>
  85.             </xul:scrollbox>
  86.             <xul:label anonid="overflow-ellipsis" class="textbox-overflow-ellipsis" hidden="true"/>
  87.           </xul:hbox>
  88.         </xul:stack>
  89.  
  90.         <children includes="hbox"/>
  91. <!-- fission: -->
  92.           </xul:hbox>
  93.         </xul:stack>
  94. <!-- /fission -->
  95.       </xul:hbox>
  96.  
  97.       <xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker"
  98.                       allowevents="true"
  99.                       xbl:inherits="open,enablehistory,parentfocused=focused"/>
  100.  
  101.       <xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
  102.     </content>
  103.  
  104.     <implementation implements="nsIDOMEventListener, nsIObserver">
  105.       <constructor><![CDATA[
  106.         try {
  107.           this.overflowEllipsis.value =
  108.             Components.classes["@mozilla.org/preferences-service;1"]
  109.                       .getService(Components.interfaces.nsIPrefBranch)
  110.                       .getComplexValue("intl.ellipsis",
  111.                                        Components.interfaces.nsIPrefLocalizedString)
  112.                       .data;
  113.         } catch (ex) {
  114.           this.overflowEllipsis.value = "\u2026";
  115.         }
  116.  
  117.         let (self = this) {
  118.           this.inputBoxInner.focus = function () {
  119.             self.inputField.focus();
  120.           };
  121.         }
  122.  
  123.         this.plain = true;
  124.       ]]></constructor>
  125.       <field name="mouseOnTopLinkifies">
  126.         this._prefs.getBoolPref("mouseOnTopLinkifies")
  127.       </field>
  128.       <field name="mouseOnBottomLinkifies">
  129.         this._prefs.getBoolPref("mouseOnBottomLinkifies")
  130.       </field>
  131.       <field name="uri"/>
  132.       <field name="hideProtocols">
  133.         this._prefs.getCharPref("hideProtocols").replace(/:\/\/$/, "").split(/[ ,/:]+/);
  134.       </field>
  135.       <field name="protocolHidden"/>
  136.       <field name="_focused"/>
  137.       <field name="_mouseover"/>
  138.       <field name="_iconWasHovered"/>
  139.       <field name="_tooltipTimer"/>
  140.       <field name="pathSegmentProto">
  141.         var node = document.createElement("label");
  142.         node.className = "textbox-presentation-segment textbox-presentation-path";
  143.         node;
  144.       </field>
  145.       <field name="inputBox">
  146.         document.getAnonymousElementByAttribute(this, "anonid", "textbox-input-box");
  147.       </field>
  148.       <field name="inputBoxInner">
  149.         document.getAnonymousElementByAttribute(this, "anonid", "textbox-input-box-inner");
  150.       </field>
  151.       <field name="presentationBox">
  152.         document.getAnonymousElementByAttribute(this, "anonid", "presentation-box");
  153.       </field>
  154.       <field name="presentation">
  155.         document.getAnonymousElementByAttribute(this, "anonid", "presentation");
  156.       </field>
  157.       <field name="overflowEllipsis">
  158.         document.getAnonymousElementByAttribute(this, "anonid", "overflow-ellipsis");
  159.       </field>
  160.       <field name="prePathNode">
  161.         document.getAnonymousElementByAttribute(this, "anonid", "prePath");
  162.       </field>
  163.       <field name="protocolNode">
  164.         document.getAnonymousElementByAttribute(this, "anonid", "protocol");
  165.       </field>
  166.       <field name="subDomainNode">
  167.         document.getAnonymousElementByAttribute(this, "anonid", "subdomain");
  168.       </field>
  169.       <field name="domainNode">
  170.         document.getAnonymousElementByAttribute(this, "anonid", "domain");
  171.       </field>
  172.       <field name="portNode">
  173.         document.getAnonymousElementByAttribute(this, "anonid", "port");
  174.       </field>
  175.       <field name="pathFileNode">
  176.         document.getAnonymousElementByAttribute(this, "anonid", "pathFile");
  177.       </field>
  178.       <field name="fileNode">
  179.         document.getAnonymousElementByAttribute(this, "anonid", "file");
  180.       </field>
  181.       <field name="queryNode">
  182.         document.getAnonymousElementByAttribute(this, "anonid", "query");
  183.       </field>
  184.       <field name="fragmentNode">
  185.         document.getAnonymousElementByAttribute(this, "anonid", "fragment");
  186.       </field>
  187.       <field name="urlTooltip">
  188.         document.getElementById("urlTooltip");
  189.       </field>
  190.       <field name="urlTooltipLabel">
  191.         this.urlTooltip.getElementsByTagName("label")[0];
  192.       </field>
  193.       <field name="_tldService" readonly="true"><![CDATA[
  194.         Components.classes["@mozilla.org/network/effective-tld-service;1"]
  195.                   .getService(Components.interfaces.nsIEffectiveTLDService);
  196.       ]]></field>
  197.       <field name="_ioService" readonly="true">
  198.         Components.classes["@mozilla.org/network/io-service;1"]
  199.                   .getService(Components.interfaces.nsIIOService);
  200.       </field>
  201.  
  202.       <field name="_plain">true</field>
  203.       <property name="plain" onget="return this._plain">
  204.         <setter><![CDATA[
  205.           this._plain = val;
  206.           if (val) {
  207.             this.inputBoxInner.style.removeProperty("opacity");
  208.             this.presentationBox.hidden = true;
  209.           } else
  210.             this.inputBoxInner.style.setProperty("opacity", "0", "important");
  211.           this.presentationBox.style.removeProperty("opacity");
  212.           this._hideURLTooltip();
  213.           return val;
  214.         ]]></setter>
  215.       </property>
  216.  
  217.       <property name="contentIsCropped"
  218.                 onget="return !this.overflowEllipsis.hidden;"
  219.                 onset="this.overflowEllipsis.hidden = !val; return val;"/>
  220.  
  221.       <property name="value"
  222.                 onget="return (this.hasAttribute('isempty') || this.hasAttribute('empty')) ? '' : this.inputField.value;">
  223.         <setter><![CDATA[
  224.           this.mIgnoreInput = true;
  225.           if (val) {
  226.             // clear the emptyText _before_ setting a new non-empty value
  227.             this._clearEmptyText();
  228.             this.inputField.value = val;
  229.           } else {
  230.             // display the emptyText _after_ setting a value that's an empty string
  231.             this.inputField.value = val;
  232.             this._updateVisibleText();
  233.           }
  234.           this.mIgnoreInput = false;
  235.           this._syncValue();
  236.           if (this._focused)
  237.             this.plain = true;
  238.           else if (!this._mouseover || !this.plain)
  239.             this.prettyView();
  240.           var event = document.createEvent("Events");
  241.           event.initEvent("ValueChange", true, true);
  242.           this.inputField.dispatchEvent(event);
  243.           return val;
  244.         ]]></setter>
  245.       </property>
  246.  
  247.       <method name="_syncValue">
  248.         <body><![CDATA[
  249.           if (this.value == "")
  250.             this.uri = null;
  251.           else try {
  252.             var uri = this._ioService.newURI(this.value, null, null);
  253.             this.uri = (typeof uri.host != "undefined") ? uri : null;
  254.           } catch(e) {
  255.             this.uri = null;
  256.           }
  257.           if (!this.uri) {
  258.             this.removeAttribute("valid-uri");
  259.             this.contentIsCropped = false;
  260.             return;
  261.           }
  262.  
  263.           this.setAttribute("valid-uri", "true");
  264.           if (!this._focused)
  265.             this.inputField.value = losslessDecodeURI(this.uri);
  266.  
  267.           var presentation = this.presentation;
  268.           var prePathNode = this.prePathNode;
  269.  
  270.           prePathNode.href =
  271.             this.protocolNode.value = this.uri.scheme + "://";
  272.           this.protocolHidden = this.hideProtocols.indexOf(this.uri.scheme) > -1;
  273.           this.subDomainNode.value = "";
  274.           this.portNode.value = "";
  275.  
  276.           var host = this.uri.host;
  277.           if (host) {
  278.             try {
  279.               let baseDomain = this._tldService.getBaseDomainFromHost(host);
  280.               this.subDomainNode.value = host.substring(0, host.lastIndexOf(baseDomain));
  281.               host = baseDomain;
  282.             } catch (e) {}
  283.             prePathNode.href += this.uri.asciiHost;
  284.             this.domainNode.value = host;
  285.             if (this.uri.port > -1)
  286.               prePathNode.href +=
  287.                 (this.portNode.value = ":" + this.uri.port);
  288.           } else
  289.             this.domainNode.value = "";
  290.           prePathNode.href += "/";
  291.  
  292.           while (prePathNode.nextSibling != this.pathFileNode)
  293.             presentation.removeChild(prePathNode.nextSibling);
  294.  
  295.           var pathSegments = losslessDecodeURI(this.uri).replace(/^[^:]*:\/\/[^/]*\//, "");
  296.  
  297.           var iFragment = pathSegments.indexOf("#");
  298.           if (iFragment > -1) {
  299.             this.fragmentNode.value = pathSegments.substring(iFragment);
  300.             pathSegments = pathSegments.substring(0, iFragment);
  301.           } else
  302.             this.fragmentNode.value = "";
  303.  
  304.           var iQuery = pathSegments.indexOf("?");
  305.           if (iQuery > -1) {
  306.             this.queryNode.value = pathSegments.substring(iQuery);
  307.             pathSegments = pathSegments.substring(0, iQuery);
  308.           } else
  309.             this.queryNode.value = "";
  310.  
  311.           pathSegments = pathSegments.split("/");
  312.           this.fileNode.value = pathSegments.pop();
  313.  
  314.           var href = prePathNode.href;
  315.           for (var i = 0; i < pathSegments.length; i++) {
  316.             var node = this.pathSegmentProto.cloneNode(true);
  317.             node.value = pathSegments[i];
  318.             node.href = (href += pathSegments[i] + "/");
  319.             presentation.insertBefore(node, this.pathFileNode);
  320.           }
  321.           this.pathFileNode.href = href + this.fileNode.value + this.queryNode.value + this.fragmentNode.value;
  322.         ]]></body>
  323.       </method>
  324.  
  325.       <method name="_prettyView">
  326.         <body><![CDATA[
  327.           this._plain = false;
  328.           this.protocolNode.hidden = false;
  329.           this.presentationBox.hidden = false;
  330.           this.subDomainNode.style.removeProperty("-moz-margin-start");
  331.           this.portNode.style.removeProperty("-moz-margin-end");
  332.           if (this.protocolHidden) {
  333.             var domainMargin = this.protocolNode.boxObject.width / 2;
  334.             this.protocolNode.hidden = true;
  335.             this.subDomainNode.style.setProperty("-moz-margin-start", Math.ceil(domainMargin) + "px", "");
  336.             this.portNode.style.setProperty("-moz-margin-end", Math.floor(domainMargin) + "px", "");
  337.           }
  338.         ]]></body>
  339.       </method>
  340.  
  341.       <method name="prettyView">
  342.         <body><![CDATA[
  343.           if (this.uri) {
  344.             this._prettyView();
  345.             this.plain = false;
  346.           } else {
  347.             this.plain = true;
  348.           }
  349.         ]]></body>
  350.       </method>
  351.  
  352.       <method name="_initURLTooltip">
  353.         <parameter name="callback"/>
  354.         <parameter name="object"/>
  355.         <parameter name="crop"/>
  356.         <body><![CDATA[
  357.           if (this._tooltipTimer)
  358.             clearTimeout(this._tooltipTimer);
  359.           this._tooltipTimer = setTimeout (function (self) {
  360.             self._tooltipTimer = 0;
  361.             var tooltipText = callback.apply(object);
  362.             if (tooltipText) {
  363.               self.urlTooltipLabel.value = tooltipText;
  364.               self.urlTooltipLabel.crop = crop || "center";
  365.               var bO = self.boxObject;
  366.               self.urlTooltip.maxWidth = bO.width;
  367.               self.urlTooltip.showPopup(self, bO.screenX, bO.screenY + bO.height, "tooltip");
  368.             }
  369.           }, 400, this);
  370.         ]]></body>
  371.       </method>
  372.  
  373.       <method name="handleEvent">
  374.         <parameter name="aEvent"/>
  375.         <body><![CDATA[
  376.           switch (aEvent.type) {
  377.             case "mousedown":
  378.               if (this.doubleClickSelectsAll &&
  379.                   aEvent.button == 0 && aEvent.detail == 2) {
  380.                 this.editor.selectAll();
  381.                 aEvent.preventDefault();
  382.               }
  383.               break;
  384.             case "keydown":
  385.               if (this.plain && this._mouseover && !this._focused) {
  386.                 switch (aEvent.keyCode) {
  387.                   case KeyEvent.DOM_VK_SHIFT:
  388.                   case KeyEvent.DOM_VK_CONTROL:
  389.                   case KeyEvent.DOM_VK_META:
  390.                   case KeyEvent.DOM_VK_ALT:
  391.                     this.prettyView();
  392.                     this.setAttribute("linkify", "true");
  393.                 }
  394.               }
  395.           }
  396.         ]]></body>
  397.       </method>
  398.  
  399.       <method name="observe">
  400.         <parameter name="subject"/>
  401.         <parameter name="topic"/>
  402.         <parameter name="data"/>
  403.         <body><![CDATA[
  404.           if (topic == "nsPref:changed") {
  405.             switch(data) {
  406.               case "hideProtocols":
  407.                 this.hideProtocols = this._prefs.getCharPref("hideProtocols").replace(/:\/\/$/, "").split(/[ ,/:]+/);
  408.                 this._syncValue();
  409.                 if (!this.plain)
  410.                   this.prettyView();
  411.                 break;
  412.               case "clickSelectsAll":
  413.               case "doubleClickSelectsAll":
  414.               case "mouseOnBottomLinkifies":
  415.               case "mouseOnTopLinkifies":
  416.                 this[data] = this._prefs.getBoolPref(data);
  417.                 break;
  418.             }
  419.           }
  420.         ]]></body>
  421.       </method>
  422.     </implementation>
  423.  
  424.     <handlers>
  425.       <handler event="input"
  426.                action="this._syncValue();"/>
  427.  
  428.       <handler event="mousemove"><![CDATA[
  429.         if (this.plain && !this._focused && this.contentIsCropped)
  430.           this._initURLTooltip(function () {
  431.             return this.plain ? this.value : null;
  432.           }, this, "start");
  433.       ]]></handler>
  434.  
  435.       <handler event="mouseover"><![CDATA[
  436.         if (this._mouseover)
  437.           return;
  438.         if (!this.plain) {
  439.           var bO = this.inputBox.boxObject;
  440.           if (event.screenX < bO.screenX || event.screenX > bO.screenX + bO.width)
  441.             return;
  442.         }
  443.         this._mouseover = true;
  444.         var bO = this.boxObject;
  445.         if (this._iconWasHovered || event.shiftKey || event.ctrlKey || event.metaKey || event.altKey ||
  446.             this.mouseOnTopLinkifies && event.screenY < bO.screenY + bO.height / 4 ||
  447.             this.mouseOnBottomLinkifies && event.screenY >= bO.screenY + bO.height / 4)
  448.           this.setAttribute("linkify", "true");
  449.         else
  450.           setTimeout (function (self) {
  451.             if (self._mouseover && self.getAttribute("linkify") != "true") {
  452.               self.plain = true;
  453.               document.addEventListener("keydown", self, false);
  454.             }
  455.           }, 60, this);
  456.       ]]></handler>
  457.  
  458.       <handler event="mouseout"><![CDATA[
  459.         for (var node = event.relatedTarget; node; node = node.parentNode)
  460.           if (node == this)
  461.             return;
  462.         this.removeAttribute("linkify");
  463.         this._mouseover = false;
  464.         this._iconWasHovered = false;
  465.         if (!this._focused && this.plain) {
  466.           this.prettyView();
  467.           document.removeEventListener("keydown", this, false);
  468.         } else
  469.           this._hideURLTooltip();
  470.       ]]></handler>
  471.  
  472.       <handler event="focus" phase="capturing"><![CDATA[
  473.         if (!this._focused && event.originalTarget == this.inputField) {
  474.           this._focused = true;
  475.           if (!this.plain)
  476.             this.plain = true;
  477.         }
  478.       ]]></handler>
  479.  
  480.       <handler event="blur" phase="capturing"><![CDATA[
  481.         if (this._focused && !this._dontBlur && event.originalTarget == this.inputField) {
  482.           this._focused = false;
  483.           this._syncValue();
  484.           if (!this._mouseover)
  485.             this.prettyView();
  486.         }
  487.       ]]></handler>
  488.     </handlers>
  489.  
  490.   </binding>
  491.  
  492.   <binding id="single-segment" display="xul:hbox" extends="chrome://locationbar2/content/urlbar.xml#segment">
  493.     <content>
  494.       <xul:label class="textbox-presentation-segment-label" anonid="label"/>
  495.       <xul:label class="textbox-presentation-slash" value="/"/>
  496.     </content>
  497.  
  498.     <implementation>
  499.       <property name="value" onget="return this.getAttribute('value');">
  500.         <setter><![CDATA[
  501.           this.setAttribute("value", val);
  502.           document.getAnonymousElementByAttribute(this, "anonid", "label").value = val;
  503.           return val;
  504.         ]]></setter>
  505.       </property>
  506.     </implementation>
  507.   </binding>
  508.  
  509.   <binding id="file-segment" extends="chrome://locationbar2/content/urlbar.xml#segment">
  510.     <content>
  511.       <children/>
  512.     </content>
  513.   </binding>
  514.  
  515.   <binding id="segment">
  516.     <content>
  517.       <children/>
  518.       <xul:label class="textbox-presentation-slash" value="/"/>
  519.     </content>
  520.  
  521.     <implementation>
  522.       <field name="href"/>
  523.     </implementation>
  524.  
  525.     <handlers>
  526.       <handler event="click"><![CDATA[
  527.         if (event.button != 2 &&
  528.             event.originalTarget != this &&
  529.             event.originalTarget.className != "textbox-presentation-slash" &&
  530.             gURLBar.getAttribute("linkify") == "true") {
  531.           openUILink(this.href, event, false, true);
  532.           event.stopPropagation();
  533.           event.preventDefault();
  534.         }
  535.       ]]></handler>
  536.  
  537.       <handler event="mousedown"><![CDATA[
  538.         if (event.button != 2 &&
  539.             event.originalTarget != this &&
  540.             event.originalTarget.className != "textbox-presentation-slash")
  541.           event.stopPropagation();
  542.       ]]></handler>
  543.  
  544.       <handler event="mouseout"><![CDATA[
  545.         for (var node = event.relatedTarget; node; node = node.parentNode)
  546.           if (node == this)
  547.             return;
  548.         gURLBar._hideURLTooltip();
  549.       ]]></handler>
  550.  
  551.       <handler event="mousemove"><![CDATA[
  552.         if (event.originalTarget != this &&
  553.             event.originalTarget.className != "textbox-presentation-slash")
  554.           gURLBar._initURLTooltip(function () {
  555.             return this.href;
  556.           }, this);
  557.         else
  558.           gURLBar._hideURLTooltip();
  559.       ]]></handler>
  560.     </handlers>
  561.  
  562.   </binding>
  563. </bindings>